package com.car.loan.project.xr.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.Collection;
import java.util.List;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.car.loan.project.xr.mapper.LoanContactMapper;
import com.car.loan.project.xr.domain.LoanContact;
import com.car.loan.project.xr.service.ILoanContactService;

/**
 * 紧急联系人Service业务层处理
 *
 * @author ruoyi
 * @date 2019-11-03
 */
@Service
public class LoanContactServiceImpl implements ILoanContactService {

    @Autowired
    private LoanContactMapper loanContactMapper;

    /**
     * 查询紧急联系人
     *
     * @param id 紧急联系人ID
     * @return 紧急联系人
     */
    @Override
    public LoanContact selectLoanContactById(Long id) {
        return loanContactMapper.selectById(id);
    }

    /**
     * 查询紧急联系人列表
     *
     * @param loanContact 紧急联系人
     * @return 紧急联系人
     */
    @Override
    public List<LoanContact> selectLoanContactList(LoanContact loanContact) {
        QueryWrapper<LoanContact> queryWrapper = new QueryWrapper<>(loanContact);
        return loanContactMapper.selectList(queryWrapper);
    }


    @Override
    public IPage<LoanContact> selectPage(IPage<LoanContact> page,
        QueryWrapper<LoanContact> queryWrapper) {
        return loanContactMapper.selectPage(page, queryWrapper);
    }

    /**
     * 新增紧急联系人
     *
     * @param loanContact 紧急联系人
     * @return 结果
     */
    @Override
    public int insertLoanContact(LoanContact loanContact) {

        return loanContactMapper.insert(loanContact);
    }

    /**
     * 修改紧急联系人
     *
     * @param loanContact 紧急联系人
     * @return 结果
     */
    @Override
    public int updateLoanContact(LoanContact loanContact) {

        return loanContactMapper.updateById(loanContact);
    }

    /**
     * 删除紧急联系人对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteLoanContactByIds(Collection<Long> ids) {
        return loanContactMapper.deleteBatchIds(ids);
    }

    /**
     * 删除紧急联系人信息
     *
     * @param id 紧急联系人ID
     * @return 结果
     */
    @Override
    public int deleteLoanContactById(Long id) {
        return loanContactMapper.deleteById(id);
    }
}
